import request from '@/utils/request'
import {BuildRecordAddDTO, BuildRecordQuery, BuildRecordUpdateDTO, BuildReq} from '@/api/build-record/models'

const commonUrl = '/sw/buildRecord'

//添加建记录
export const addBuildRecordApi = (data: BuildRecordAddDTO) => {
    return request({
        url: `${commonUrl}/addBuildRecord`, // 假设创建模板的API路径
        method: 'post',
        data // 将数据传递到请求体中
    })
}

//构建与预览
export const buildPreviewApi = (data: BuildReq) => {
    return request({
        url: `${commonUrl}/buildPreview`, // 假设创建模板的API路径
        method: 'post',
        data // 将数据传递到请求体中
    })
}

//构建与下载
export const buildZip = (data: BuildReq) => {
    return request({
        url: `${commonUrl}/buildZip`, // 假设创建模板的API路径
        method: 'post',
        responseType: 'arraybuffer',
        data // 将数据传递到请求体中
    })
}

//更新建记录
export const updateBuildRecordApi = (data: BuildRecordUpdateDTO) => {
    return request({
        url: `${commonUrl}/updateBuildRecord`, // 假设创建模板的API路径
        method: 'put',
        data // 将数据传递到请求体中
    })
}

//建记录分页
export const pageBuildRecordApi = (params: BuildRecordQuery) => {
    return request({
        url: `${commonUrl}/pageBuildRecord`,
        method: 'get',
        params: params
    })
}

//建记录详情
export const getOneBuildRecordApi = (id: string) => {
    return request({
        url: `${commonUrl}/getOneBuildRecord`,
        method: 'get',
        params: {id}
    })
}


//删除建记录
export const deleteBuildRecordApi = (id: string) => {
    return request({
        url: `${commonUrl}/deleteBuildRecord`,
        method: 'delete',
        params: {id}
    })
}
